package top.leyi.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import top.leyi.entity.Class;
import top.leyi.entity.College;

import java.util.List;

public interface ClassMapper {

    @Insert("INSERT INTO clazz(name, col_id) VALUES(#{name}, #{col_id})")
    void insertClass(Class clazz);

    /**
     * 根据班级id查询班级
     * @param clazz
     * @return
     */
    @Select("SELECT id FROM class WHERE id = #{id}")
    int queryClass(Class clazz);

      /**
     * 根据个人信息查询班级id
     * @param  userId
     * @return
     */
    @Select("SELECT * FROM class WHERE id = (" +
            "SELECT classId FROM user WHERE id = #{userId})")
    Class queryClassData(int userId);

    /**
     *@descripe 查询所有班级
     * @param  userId
     * @return
     */
    @Select("SELECT * FROM class")
    List<Class> queryAllClassData( );
    /**
     * 查询班级id
     * @param  userId
     * @return
     */
    @Select("SELECT * FROM class where col_id = #{value}")
    List<Class> queryAllClassWithCol( int col_id);

    /**
     * 查询所有的学院信息
     * @return
     */
    @Select("SELECT * FROM college")
    List<College> queryAllCollege( );

}
